package com.gimi.cloud.bbp.dao.dao.page;

import com.gimi.cloud.bbp.dao.myMapper.MyMapper;
import com.gimi.cloud.bbp.dto.page.PageColumnDTO;
import com.gimi.cloud.bbp.entity.page.PageColumn;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface PageColumnDao extends MyMapper<PageColumn>{
	
	@Select("select * from pc_page_column where is_delete = '0' and page_id= #{pageId} and display = '0' order by sort asc")
	@Results({
		@Result(property = "id", column = "id"),
		@Result(property = "pageColumns", column = "id" , many = @Many(select = ("com.gimi.cloud.bbp.dao.dao.page.PageColumnDao.getPageColumnByPId"))),
		@Result(property = "PageModel", column = "id" , one = @One(select = ("com.gimi.cloud.bbp.dao.dao.page.PageModelDao.getPageModelByColumnId")))
	})
	List<PageColumnDTO> getPageColumnByPageId(Integer PageId);
	
	@Select("select * from pc_page_column where is_delete = '0' and p_id= #{pId} order by sort asc")
	@Results({
		@Result(property = "id", column = "id"),
		@Result(property = "pageColumns", column = "id" , many = @Many(select = ("com.gimi.cloud.bbp.dao.dao.page.PageColumnDao.getPageColumnByPId"))),
		@Result(property = "PageModel", column = "id" , one = @One(select = ("com.gimi.cloud.bbp.dao.dao.page.PageModelDao.getPageModelByColumnId")))
	})
	PageColumnDTO getPageColumnByPId(Integer pId);
	
	@Select("select * from pc_page_column where is_delete = '0' and id= #{id} order by sort asc")
	@Results({
		@Result(property = "id", column = "id"),
		@Result(property = "pageColumns", column = "id" , many = @Many(select = ("com.gimi.cloud.bbp.dao.dao.page.PageColumnDao.getPageColumnByPId"))),
		@Result(property = "PageModel", column = "id" , one = @One(select = ("com.gimi.cloud.bbp.dao.dao.page.PageModelDao.getPageModelByColumnId")))
	})
	PageColumnDTO getPageColumnById(Integer id);

	@Update("update pc_page_column set is_delete = '1' where id in (${ids})")
	Long delById(@Param("ids") String ids);

}
